<template>
	<view>
		<u-loading-page :loading="loadding" loading-mode="semicircle" loading-text="Hello Pro"></u-loading-page>
		<view class="banner_box" v-if="!loadding">
			<view class="" style="display: flex; justify-content: space-between;">
				<view class=""></view>
				<message :color="'fff'"></message>
			</view>
			<view class="banner_tit">
				<view class="banner_tit_flex" @click="data_info(0)" style="text-align: center;">
					<text>昨日收益</text>
					<h3>{{getIndexData.day_profit}}</h3>
				</view>
				<view class="banner_tit_flex" @click="data_info(1)" style="text-align: center;">
					<text>本月收益</text>
					<h3>{{getIndexData.month_profit}}</h3>
				</view>
			</view>
			<view class="check">
				<image :showLoading="true" src="/static/home_bt.png" @click="joins()"></image>
			</view>
		</view>
		<view v-if="versionHref == 'version1' && activity_state" class="activity">
			<image src="/static/subsidys.png" @click="subsidy()"></image>
		</view>
		<view class="banner_cont">
			<view class="banner_list" @click="data_info_">
				<text class="H">{{getIndexData.active_month}}</text>
				<text>本月激活</text>
			</view>
			<view class="banner_list" @click="data_info_">
				<text class="H">{{getIndexData.active_today}}</text>
				<text>昨日激活</text>
			</view>
			<view class="banner_list" @click="data_info_">
				<text class="H">{{getIndexData.active_total}}</text>
				<text>累计激活</text>
			</view>
		</view>
		<view class="manage_box" v-if="!loadding">
			<view class="manage_box_outer">
				<!-- <view class="manage_list" v-for="(list,index) in menu" :key="index" @click="manage(list.path)">
					<image class="img" :src="src + list.logo_image" mode="aspectFit"></image>
					<text>{{list.name}}</text>
				</view> -->

				
				<view class="operationClass">
					<view class="titles">
						操作类
					</view>
					<u-line></u-line>
					<view v-if="firstTime == 1" class="menuList">
						<view class="manage_list"
							@click="manage('/pages/version5/index/subscription/index')">
							<image class="img" src="/static/subscription.png" mode="aspectFit"></image>
							<text>终端认购</text>
						</view>
					</view>
					<view v-if="firstTime == 2" class="menuList">
						<view v-for="(item,index) in menu[1]" :key="index" class="manage_list"
							@click="manage(item.path)">
							<image class="img" :src="src + item.logo_image" mode="aspectFit"></image>
							<text>{{item.name}}</text>
						</view>
						<!-- <view class="manage_list" @click="manage('/pages/version5/index/shop/index')">
							<image class="img" src="/static/purchase.png" mode="aspectFit"></image>
							<text>终端采购</text>
						</view>
						<view class="manage_list"
							@click="manage('/pages/version5/index/shop/order/types')">
							<image class="img" src="/static/order.png" mode="aspectFit"></image>
							<text>终端订单</text>
						</view>
						<view class="manage_list" @click="manage('/pages/version5/index/bill/lists')">
							<image class="img" src="/static/bill.png" mode="aspectFit"></image>
							<text>账单管理</text>
						</view> -->
					</view>
				</view>
				
				<view v-if="firstTime == 2" class="operationClass">
					<view class="titles">
						数据类
					</view>
					<u-line></u-line>
					<view class="menuList">
						<view v-for="(item,index) in menu[2]" :key="index" class="manage_list"
							@click="manage(item.path)">
							<image class="img" :src="src + item.logo_image" mode="aspectFit"></image>
							<text>{{item.name}}</text>
						</view>
						<!-- <view class="manage_list" @click="manage('/pages/version5/data/standard/index?type=2')">
							<image class="img" src="/static/standard.png" mode="aspectFit"></image>
							<text>达标数据</text>
						</view>
						<view class="manage_list"
							@click="manage('/pages/version5/data/flow/index?type=2')">
							<image class="img" src="/static/flowrate.png" mode="aspectFit"></image>
							<text>流量数据</text>
						</view>
						<view class="manage_list" @click="manage('/pages/version5/data/team/team5')">
							<image class="img" src="/static/teamss.png" mode="aspectFit"></image>
							<text>团队数据</text>
						</view> -->
					</view>
				</view>
			</view>
		</view>
		<u-modal :show="orderShow" title="订单通知" :content='orderMsg' confirmText="去处理" cancelText="忽略"
			:showCancelButton="true" @confirm="confirmOrder" @cancel="orderShow = false"></u-modal>
	</view>
</template>

<script>
	import message from '@/component/message.vue'
	var util5 = require('@/util/request5.js');
	export default {
		data() {
			return {
				loadding: true,
				orderShow: false,
				getIndexData: {},
				activity: {},
				activity_state: false,
				yesterday: null,
				menu: [],
				src: '',
				version: '',
				versionHref: 'version5',
				firstTime: 1,
				userinfo: {},
				orderMsg: '',
			}
		},
		components: {
			message
		},
		onLoad() {
			this.userinfo = uni.getStorageSync('userinfo');
			if (this.userinfo.is_verify == 2) {
				uni.navigateTo({
					url: '/pages/' + this.versionHref + '/mine/realname/realname'
				})
			}
			this.getCurrentTime()
			this.src = util5.realm_name.substr(0, util5.realm_name.length - 5)
			this._getIndexData5()
			this._menu5()
			this.versionHref = 'version5'
			uni.setTabBarItem({
				index: 1,
				visible: true
			})
			this.checkLoginFirstTime()
			this.getUnFinishOrder()
		},
		onShow() {
			this.checkLoginFirstTime()
		},
		methods: {
			//获取时间
			getCurrentTime() {
				let Time = new Date();
				Time.setTime(Time.getTime() - 24 * 60 * 60 * 1000);
				this.yesterday = Time.getFullYear() + "-" + (Time.getMonth() + 1) + "-" + Time.getDate();
			},
			// 获取栏目
			async _menu5() {
				const {
					data: res
				} = await this.$myHttp5({
					url: 'menu/getMenu',
					header: {
						'token': this.userinfo.token
					}
				});
				if (res.code == 1) {
					this.menu = res.data
					uni.setStorageSync('menu', res.data);
				}
			},
			// 获取激活统计数据
			async _getIndexData5() {
				const {
					data: res
				} = await this.$myHttp5({
					url: 'v1/getIndexData',
					header: {
						'token': this.userinfo.token
					}
				});
				this.loadding = false
				this.getIndexData = res.data
			},
			// 检测用户是否认购
			async checkLoginFirstTime() {
				const {
					data: res
				} = await this.$myHttp5({
					url: 'user/check_login_first_time',
					header: {
						'token': this.userinfo.token
					}
				});
				if (res.code == 1) {
					this.firstTime = res.data
				}
			},
			// 获取订单通知
			async getUnFinishOrder() {
				const {
					data: res
				} = await this.$myHttp5({
					url: 'order/getUnFinishOrder',
					header: {
						'token': this.userinfo.token
					}
				});
				if (res.code == 1) {
					this.orderMsg = res.data
					this.orderShow = true
				}
			},
			// 终端设置
			manage(path) {
				uni.navigateTo({
					url: path
				})
			},
			// 数据详情
			data_info(id) {
				uni.navigateTo({
					url: '/pages/' + this.versionHref + '/mine/account/account?id=' + id
				})
			},
			// 激活详情
			data_info_() {
				return false
				uni.navigateTo({
					url: '/pages/' + this.versionHref + '/data/active/data_info?type=1'
				})
			},
			// 推广详情
			joins() {
				uni.navigateTo({
					url: '/pages/' + this.versionHref + '/mine/aboutus/aboutus?id=1&name=业务推广'
				})
			},
			// 高温补贴
			subsidy() {
				uni.navigateTo({
					url: '/pages/' + this.versionHref + '/index/activity/subsidy/index'
				})
			},
			// 订单通知 - 确定
			confirmOrder() {
				uni.navigateTo({
					url: '/pages/' + this.versionHref + '/index/shop/order/index?type=2'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #f3f4f6;
	}
	
	.banner_box {
		display: flex;
		flex-direction: column;
		background: url('/static/top_bg.png') no-repeat center;
		background-size: 100% 100%;
		height: 560rpx;
		border-bottom-left-radius: 20rpx;
		border-bottom-right-radius: 20rpx;
		padding: 0 26rpx;
		position: relative;

		.banner_tit {
			// padding: 0 70rpx;
			box-sizing: border-box;
			display: flex;

			.banner_tit_flex {
				flex: 1;

				flex-direction: column;
				align-items: center;

				h3 {
					color: #fff;
					font-size: 56rpx;
					margin-bottom: 10rpx;
				}

				text {
					font-size: 24rpx;
					color: #bfe2ff;
				}
			}

		}
	}

	.activity {
		margin-top: 40rpx;
		padding: 0 20rpx;

		image {
			width: 100%;
			height: 120rpx;
		}
	}

	.banner_cont {
		padding: 50rpx 0rpx;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		width: 90%;
		background: url(@/static/sj_bg.jpg)no-repeat center;
		margin: 30rpx auto 0 auto;
		border-radius: 5px;
		box-shadow: 0px 0px 20px -12px #342f2f;

		.banner_list {
			display: flex;
			flex-direction: column;
			flex: 1;

			.H {
				font-size: 34rpx !important;
				color: #8d5c25;
				padding-bottom: 20rpx;

			}

			text {
				font-size: 28rpx;
				color: #9f7935;
				text-align: center;

			}
		}
	}

	.manage_box {
		display: flex;
		flex-direction: column;
		padding: 0 36rpx 30rpx 36rpx;

		.manage_box_outer {
			.operationClass {
				margin-top: 30rpx;
				background-color: #fff;
				border-radius: 16rpx;
				box-shadow: 0px 0px 20px -12px #342f2f;
				.titles {
					font-weight: bold;
					font-size: 30rpx;
					padding: 20rpx 30rpx;
				}
				.menuList {
					display: flex;
					flex-wrap: wrap;
					padding-top: 20rpx;
					.manage_list {
						display: flex;
						flex-direction: column;
						align-items: center;
						min-width: 25%;
						margin-bottom: 20rpx;

						.img {
							width: 80rpx;
							height: 80rpx;
						}
					}
				}
			}
		}

		text {
			font-size: 28rpx;

			line-height: 50rpx;
			;
		}

	}

	.check {
		position: absolute;
		left: 50%;
		transform: translate(-50%, -50%);
		bottom: -7%;
		font-size: 0;
		width: 198rpx;
		height: 54rpx;

		// background: url('@/static/home_bt.png') no-repeat center;

		image {
			display: flex;
			width: 95px;
			height: 100%;
		}
	}
</style>